// eslint-disable-next-line import/no-extraneous-dependencies
import Mock from 'mockjs';
import { menuList, partialMenuListAboutReact } from './share.data';

export default {
  'POST /login': (req, res) => {
    const data = Mock.mock({
      success: true,
      data: {
        user: {
          username: 'zrf',
        },
        token: 'i am token hi hi hi',
        role: req.body?.username || 'admin',
      },
    });
    res.json(data);
  },
  'GET /menu': (req, res) => {
    const { role } = req.query;
    let menu = [];
    switch (role) {
      case 'admin':
        menu = menuList;
        break;
      case 'react':
        menu = partialMenuListAboutReact;
        break;
      default:
    }
    const data = Mock.mock({
      success: true,
      data: [{ platform: '姬霓太美平台', children: menu }],
    });
    res.json(data);
  },
};
